﻿using System;
using com.cruxomatic.views.Administration;
using com.cruxomatic.controllers;
using com.cruxomatic.controllers.Administration;

public partial class Administration_Default : BaseView, IDefaultAdministration
{
    DefaultAdministrationController _controller = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        _controller = new DefaultAdministrationController(this);
        _controller.InitView(IsPostBack);
        if (!Page.IsPostBack)
        {
            #region Site Map
            UrlTreeNodeItems.SetSiteNavigation(PageSiteMap, UrlTreeNodeItems.Admin);
            #endregion
        }
    }
    
    protected void lnkManageCompanies_Click(object sender, EventArgs e)
    {
        _controller.OpenManageCompanies();
    }

    #region IDefaultAdministration Members

    public bool ShowManageAllCompanies
    {
        set { pnlManageAllCompanies.Visible = value; }
    }

    public bool ShowCompaniesToUsers
    {
        set { pnlAssignUsersToCompanies.Visible = value; }
    }
    #endregion

    #region IDefaultAdministration Members

    public int UserID
    {
        get 
        {
            SessionData sessionData = new SessionData();
            return sessionData.CurrentUser.UserID;
        }
    }

    #endregion
    protected void lnkManageMyCompany_Click(object sender, EventArgs e)
    {
        SessionData sessiondata = new SessionData();
        _controller.OpenManageMyCompany(sessiondata.CurrentCompany.CompanyID);
    }
    protected void lnkResetMyPassword_Click(object sender, EventArgs e)
    {
        _controller.OpenResetMyPassword();
    }
    protected void lnkEmailNotification_Click(object sender, EventArgs e)
    {
        _controller.OpenEmailNotification();
    }
    
    protected void lnkAssignUserToCompanies_Click(object sender, EventArgs e)
    {
        _controller.AssignUsersToCompanies();
    }

    #region IDefaultAdministration Members


    public bool ShowManageMyCompany
    {
        set { pnlManageMyCompany.Visible = value; }
    }

    public bool ShowResetMyPassword
    {
        set { pnlResetMyPassword.Visible = value; }
    }

    public bool ShowManageRoles
    {
        set { pnlManageRoles.Visible = value; }
    }
    public bool ShowEmalNotification
    {
        set { pnlEmalNotification.Visible = value; }
    }

    public bool ShowMasterLocations
    {
        set
        {
            pnlMasterLocations.Visible = value;
        }
    }

    #endregion

    protected void lnkManageRoles_Click(object sender, EventArgs e)
    {
        _controller.OpenManageRoles();
    }

    protected void lnkMasterLocations_Click(object Sender, EventArgs E)
    {
        _controller.OpenMasterLocations();
    }
}
